package Q1;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        Arrays.sort(arr);

        int ret = Integer.MAX_VALUE;
        int left = 0, right = 1;
        while (right < n) {
            ret = Math.min(ret, arr[right] - arr[left]);
            left++;
            right++;
        }

        System.out.println(ret);
    }
}
